package com.tools.scanner.ui.qrcode.scanner

import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import com.google.mlkit.vision.barcode.common.Barcode
import com.tools.scanner.R
import com.tools.scanner.databinding.FragmentLocationScannerBinding
import com.tools.scanner.utils.search

class GeoFragment : BaseScannerFragment() {

    private lateinit var mBinding: FragmentLocationScannerBinding

    override fun onCreateView(
        inflater: LayoutInflater,
        container: ViewGroup?,
        savedInstanceState: Bundle?
    ): View {
        mBinding = FragmentLocationScannerBinding.inflate(inflater, container, false)
        return mBinding.root
    }

    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)

        val geoPoint = getData(Barcode.GeoPoint::class.java) ?: return

        mBinding.tvLon.text = geoPoint.lng.toString()
        mBinding.tvLat.text = geoPoint.lat.toString()

        mBinding.tvSearch.setOnClickListener {
            geoPoint.search()
        }
    }

}